package com.ruoyi.web.controller.clothing;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.clothing.domain.SysTypeDetail;
import com.ruoyi.clothing.service.ISysTypeDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 款式类别管理Controller
 *
 * @author weh
 * @date 2024-01-13
 */
@RestController
@RequestMapping("/clothing/detail")
public class SysTypeDetailController extends BaseController
{
    @Autowired
    private ISysTypeDetailService sysTypeDetailService;

    /**
     * 查询款式类别管理列表
     */
//    @PreAuthorize("@ss.hasPermi('clothing:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTypeDetail sysTypeDetail)
    {
        startPage();
        List<SysTypeDetail> list = sysTypeDetailService.selectSysTypeDetailList(sysTypeDetail);
        return getDataTable(list);
    }

    /**
     * 导出款式类别管理列表
     */
//    @PreAuthorize("@ss.hasPermi('clothing:detail:export')")
    @Log(title = "款式类别管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTypeDetail sysTypeDetail)
    {
        List<SysTypeDetail> list = sysTypeDetailService.selectSysTypeDetailList(sysTypeDetail);
        ExcelUtil<SysTypeDetail> util = new ExcelUtil<SysTypeDetail>(SysTypeDetail.class);
        util.exportExcel(response, list, "款式类别管理数据");
    }

    /**
     * 获取款式类别管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('clothing:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysTypeDetailService.selectSysTypeDetailById(id));
    }

    /**
     * 新增款式类别管理
     */
//    @PreAuthorize("@ss.hasPermi('clothing:detail:add')")
    @Log(title = "款式类别管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTypeDetail sysTypeDetail)
    {
        return toAjax(sysTypeDetailService.insertSysTypeDetail(sysTypeDetail));
    }

    /**
     * 修改款式类别管理
     */
//    @PreAuthorize("@ss.hasPermi('clothing:detail:edit')")
    @Log(title = "款式类别管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTypeDetail sysTypeDetail)
    {
        return toAjax(sysTypeDetailService.updateSysTypeDetail(sysTypeDetail));
    }

    /**
     * 删除款式类别管理
     */
//    @PreAuthorize("@ss.hasPermi('clothing:detail:remove')")
    @Log(title = "款式类别管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysTypeDetailService.deleteSysTypeDetailByIds(ids));
    }
}
